package com.gxuwz.service;

import java.util.List;

import com.gxuwz.common.ICrud;
import com.gxuwz.dao.UserDao;
import com.gxuwz.entity.User;
import com.gxuwz.util.DateUtil;

public class UserService implements ICrud<User>{
	
	private UserDao userDao = null;

	@Override
	public boolean insert(User t) {
		userDao = new UserDao();
		// 设置创建时间
		t.setCreateTime(DateUtil.getCurrentTime());
		return userDao.insert(t);
	}

	@Override
	public boolean delete(String id) {
		userDao = new UserDao();
		return userDao.delete(id);
	}

	@Override
	public boolean update(User t) {
		userDao = new UserDao();
		return userDao.update(t);
	}

	@Override
	public User findById(String id) {
		userDao = new UserDao();
		return userDao.findById(id);
	}

	@Override
	public List<User> findAll() {
		userDao = new UserDao();
		return userDao.findAll();
	}
	
	public User findByUsernameAndPassword(String username,String password){
		userDao = new UserDao();
		return userDao.findByUsernameAndPassword(username,password);
	}
	
	public List<User> findByUsername(String username){
		userDao = new UserDao();
		return userDao.findByUsername(username);
	}

}
